package com.dlc.shop.systemtest.data.amount;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import com.dlc.shop.discount.common.model.Discount;
import com.dlc.shop.discount.common.model.DiscountItem;
import com.dlc.shop.discount.common.model.DiscountProd;
import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

/**
 * @author lanhai
 */
public class DiscountData {

    public static Discount getDiscount(Double maxReduceAmount, Integer discountRule, Integer discountType, List<DiscountProd> discountProds, List<DiscountItem> discountItems, Integer suitableProdType){
        Discount discount = new Discount();
        discount.setDiscountName("折扣接口测试2");
        discount.setDiscountItems(discountItems);
        discount.setDiscountProds(discountProds);
        discount.setDiscountRule(discountRule);
        discount.setDiscountType(discountType);
        discount.setStartTime(DateUtil.parse("2021-1-1 00:00:00","yyyy-MM-dd HH:mm:ss"));
        discount.setEndTime(DateUtil.parse("2025-1-1 00:00:00","yyyy-MM-dd HH:mm:ss"));
        discount.setMaxReduceAmount(maxReduceAmount);
        discount.setMobilePic("test.png");
        discount.setPcBackgroundPic("test.png");
        discount.setPcPic("test.png");
        discount.setStatus(1);
        discount.setSuitableProdType(suitableProdType);
        return discount;
    }

    public static List<DiscountProd> getDisconutProds(List<Long> prodIds){
        List<DiscountProd> discountProds = new ArrayList<>();
        for (Long prodId : prodIds) {
            DiscountProd discountProd = new DiscountProd();
            discountProd.setProdId(prodId);
            discountProd.setProdName("xxx");
            discountProd.setProdStatus(1);
            discountProd.setPic("test.png");
            discountProds.add(discountProd);
        }
        return discountProds;
    }
    public static  List<DiscountItem>  getDiscountItems(List<DiscoutItemDto> discoutItemDtos){
        List<DiscountItem> discountItemList = new ArrayList<>();
        for (DiscoutItemDto discoutItemDto : discoutItemDtos) {
            discountItemList.add(BeanUtil.copyProperties(discoutItemDto, DiscountItem.class));
        }
        return discountItemList;
    }

    @Data
    @AllArgsConstructor
    public static class DiscoutItemDto{
        Double needAmount;
        Double discount;
    }

}
